import pandas as pd
import json

# 示例数据 - JSON对象列表
json_data = [
{
            "nodeId": "1",
            "treeId": "1",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/1504ef3f-44bf-4eed-b86b-98bff9fe7ba1",
            "subjectId": 1
        },
        {
            "nodeId": "2",
            "treeId": "2",
            "nodeName": "新人教A版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/f8dfffbb-f4d2-41dc-8ecd-6a2009813a97",
            "subjectId": 2
        },
        {
            "nodeId": "6",
            "treeId": "6",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/a625d570-8be7-4c08-990b-40732055d147",
            "subjectId": 6
        },
        {
            "nodeId": "4",
            "treeId": "4",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/0eb68df4-8cff-4e55-9f23-04b94233817f",
            "subjectId": 4
        },
        {
            "nodeId": "10",
            "treeId": "10",
            "nodeName": "浙教版2019新教材",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/3f8b8fe8-62a7-46c5-9a71-43a464b7f7f5",
            "subjectId": 10
        },
        {
            "nodeId": "11",
            "treeId": "11",
            "nodeName": "通用版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/6b14b71d-4ff2-4260-b48a-4893b96507de",
            "subjectId": 11
        },
        {
            "nodeId": "7",
            "treeId": "7",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/02e41ffe-e50a-4a0a-8225-e74a3fd8dbf7",
            "subjectId": 7
        },
        {
            "nodeId": "8",
            "treeId": "8",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/3d052d24-2823-4dd0-b823-bce06de56815",
            "subjectId": 8
        },
        {
            "nodeId": "3",
            "treeId": "3",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/83d094fe-3759-48c2-86b5-956f0eeac403",
            "subjectId": 3
        },
        {
            "nodeId": "5",
            "treeId": "5",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/e936fdfb-699f-4923-81d1-398293fc7928",
            "subjectId": 5
        },
        {
            "nodeId": "599",
            "treeId": "9",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/4e29d51c-e76e-4095-89ca-d2490666d7b1",
            "subjectId": 9
        },
        {
            "nodeId": "539",
            "treeId": "3",
            "nodeName": "新外研版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/cc18f15d-21a5-4853-90e8-636358597a88",
            "subjectId": 3
        },
        {
            "nodeId": "555",
            "treeId": "5",
            "nodeName": "新鲁科版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/1137f8d3-dd14-496b-b20b-938e30453500",
            "subjectId": 5
        },
        {
            "nodeId": "601",
            "treeId": "9",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/6e3df5ad-065d-48d6-8f28-0eba934431c7",
            "subjectId": 9
        },
        {
            "nodeId": "504",
            "treeId": "2",
            "nodeName": "新人教B版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/c5df6eba-6975-4ac2-902d-4a17d02e16fc",
            "subjectId": 2
        },
        {
            "nodeId": "563",
            "treeId": "6",
            "nodeName": "新浙科版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/bad7db6f-e3a6-48d0-bef8-869d5542d92c",
            "subjectId": 6
        },
        {
            "nodeId": "545",
            "treeId": "4",
            "nodeName": "新鲁科版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/de2b8b7a-2206-47d5-963c-5e0eec55203e",
            "subjectId": 4
        },
        {
            "nodeId": "541",
            "treeId": "3",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/915ee2c4-ffd7-4532-82b0-f2f9da88db26",
            "subjectId": 3
        },
        {
            "nodeId": "557",
            "treeId": "5",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/dbefe9f1-f27c-47e7-b97f-d304ccacd1c3",
            "subjectId": 5
        },
        {
            "nodeId": "603",
            "treeId": "9",
            "nodeName": "新中图版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/4824659d-677d-4a9d-9029-d640d342caae",
            "subjectId": 9
        },
        {
            "nodeId": "506",
            "treeId": "2",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/b5d8711c-308a-4576-a3c3-aa2a37b490e9",
            "subjectId": 2
        },
        {
            "nodeId": "565",
            "treeId": "6",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/3991d814-89c0-4d34-9844-d6ba5e661cc9",
            "subjectId": 6
        },
        {
            "nodeId": "547",
            "treeId": "4",
            "nodeName": "新教科版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/35c412f1-38af-437b-b96e-00084809754b",
            "subjectId": 4
        },
        {
            "nodeId": "543",
            "treeId": "3",
            "nodeName": "新译林版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/f91492ce-c039-4ab8-8ae9-010150feb58f",
            "subjectId": 3
        },
        {
            "nodeId": "605",
            "treeId": "9",
            "nodeName": "新鲁教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/a503f6e1-ff17-40e6-8a9a-3409363559a8",
            "subjectId": 9
        },
        {
            "nodeId": "508",
            "treeId": "2",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/45051440-68a6-4f13-b05a-3c9e5c7ef4e7",
            "subjectId": 2
        },
        {
            "nodeId": "549",
            "treeId": "4",
            "nodeName": "新粤教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/bd83ad20-5f7c-482f-890d-e3017dafa543",
            "subjectId": 4
        },
        {
            "nodeId": "512",
            "treeId": "2",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/1de2b900-a929-4689-9c92-1f280e604236",
            "subjectId": 2
        }
]

test_json_data = [
{
            "nodeId": "36127",
            "treeId": "192",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 4
        },
        {
            "nodeId": "20011",
            "treeId": "12",
            "nodeName": "通用版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 11
        },
        {
            "nodeId": "20006",
            "treeId": "7",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9341",
            "treeId": "9",
            "nodeName": "treeId9-层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "9158",
            "treeId": "6",
            "nodeName": "treeId6-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "102",
            "treeId": "3",
            "nodeName": "人教A版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20599",
            "treeId": "10",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "20005",
            "treeId": "6",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "9121",
            "treeId": "4",
            "nodeName": "treeId4-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "101",
            "treeId": "2",
            "nodeName": "（陈超添加）层级1-节点11",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "107",
            "treeId": "8",
            "nodeName": "人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "20003",
            "treeId": "4",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "110",
            "treeId": "11",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 10
        },
        {
            "nodeId": "106",
            "treeId": "7",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "20002",
            "treeId": "3",
            "nodeName": "新人教A版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20010",
            "treeId": "11",
            "nodeName": "浙教版2019新教材",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 10
        },
        {
            "nodeId": "20008",
            "treeId": "9",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "111",
            "treeId": "12",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 11
        },
        {
            "nodeId": "20007",
            "treeId": "8",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "9510",
            "treeId": "10",
            "nodeName": "G教1更1他1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "9541",
            "treeId": "10",
            "nodeName": "教22",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "20001",
            "treeId": "2",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "https://cdn.ewt360.com/resources/school-admin/uploads/2025/5/26/1504ef3f-44bf-4eed-b86b-98bff9fe7ba1",
            "subjectId": 1
        },
        {
            "nodeId": "20563",
            "treeId": "7",
            "nodeName": "新浙科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9466",
            "treeId": "9",
            "nodeName": "测试超过数目9",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20601",
            "treeId": "10",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "9122",
            "treeId": "4",
            "nodeName": "treeId4-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20555",
            "treeId": "6",
            "nodeName": "新鲁科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "9109",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点2改编111",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "9094",
            "treeId": "2",
            "nodeName": "（西瓜添加）层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "9190",
            "treeId": "8",
            "nodeName": "treeId8-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "20539",
            "treeId": "4",
            "nodeName": "新外研版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "9168",
            "treeId": "7",
            "nodeName": "treeId7-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "20504",
            "treeId": "3",
            "nodeName": "新人教B版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "10596",
            "treeId": "2",
            "nodeName": "(小峰)层级1-1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "20565",
            "treeId": "7",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9097",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20603",
            "treeId": "10",
            "nodeName": "新中图版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "10931",
            "treeId": "9",
            "nodeName": "测试一级节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20557",
            "treeId": "6",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "9193",
            "treeId": "8",
            "nodeName": "treeId8-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "20541",
            "treeId": "4",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "9169",
            "treeId": "7",
            "nodeName": "treeId7-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "20506",
            "treeId": "3",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20508",
            "treeId": "3",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "10912",
            "treeId": "9",
            "nodeName": "一级节点新增测试",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20605",
            "treeId": "10",
            "nodeName": "新鲁教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "10020",
            "treeId": "2",
            "nodeName": "（创业添加）",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11029",
            "treeId": "8",
            "nodeName": "小峰政治1级",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "20543",
            "treeId": "4",
            "nodeName": "新译林版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20512",
            "treeId": "3",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "9116",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "10936",
            "treeId": "9",
            "nodeName": "小峰1级",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "10172",
            "treeId": "2",
            "nodeName": "巴顿添加",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "9491",
            "treeId": "2",
            "nodeName": "（凯利添加）层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11030",
            "treeId": "9",
            "nodeName": "小峰1级2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "10184",
            "treeId": "2",
            "nodeName": "测试节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11151",
            "treeId": "2",
            "nodeName": "张伟伟测试2",
            "isShow": 1,
            "imageUrl": "https://test-si.ewt360.com/resources/school-admin/uploads/2024/10/31/8b79fd74-c91b-45e3-9b43-5d9cb8452853.png",
            "subjectId": 1
        },
        {
            "nodeId": "11418",
            "treeId": "2",
            "nodeName": "byt教材版本0919测试byt教材版本0919测试byt教材版本0919测试",
            "isShow": 1,
            "imageUrl": "https://test-si.ewt360.com/resources/school-admin/uploads/2024/10/31/8b79fd74-c91b-45e3-9b43-5d9cb8452853.png",
            "subjectId": 1
        },
        {
            "nodeId": "11467",
            "treeId": "2",
            "nodeName": "人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11526",
            "treeId": "2",
            "nodeName": "有教材版本无书本节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11528",
            "treeId": "2",
            "nodeName": "有教材有书本无章节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11534",
            "treeId": "2",
            "nodeName": "有教材有书本有章节,章节资源为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11540",
            "treeId": "2",
            "nodeName": "有教材有书本有章有节,节点资源为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36048",
            "treeId": "2",
            "nodeName": "教材版本是自尊会员",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36008",
            "treeId": "2",
            "nodeName": "书本层级以下测试自尊会员",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36010",
            "treeId": "2",
            "nodeName": "书本层级以下测试节点隐藏逻辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36058",
            "treeId": "2",
            "nodeName": "教材版本测试节点隐藏逻辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36070",
            "treeId": "2",
            "nodeName": "自尊会员引起的书本层级为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36088",
            "treeId": "2",
            "nodeName": "隐藏节点引起的书本层级为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "36131",
            "treeId": "2",
            "nodeName": "空教材版本1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        }
]

dev_json_data = [
        {
            "nodeId": "20001",
            "treeId": "2",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11560",
            "treeId": "192",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 4
        },
        {
            "nodeId": "110",
            "treeId": "11",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 10
        },
        {
            "nodeId": "106",
            "treeId": "7",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "102",
            "treeId": "3",
            "nodeName": "人教A版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20008",
            "treeId": "9",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20010",
            "treeId": "11",
            "nodeName": "浙教版2019新教材",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 10
        },
        {
            "nodeId": "20007",
            "treeId": "8",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "9121",
            "treeId": "4",
            "nodeName": "treeId4-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "9510",
            "treeId": "10",
            "nodeName": "G教1更1他1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "101",
            "treeId": "2",
            "nodeName": "（陈超添加）层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "111",
            "treeId": "12",
            "nodeName": "待编辑",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 11
        },
        {
            "nodeId": "20006",
            "treeId": "7",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9341",
            "treeId": "9",
            "nodeName": "treeId9-层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20011",
            "treeId": "12",
            "nodeName": "通用版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 11
        },
        {
            "nodeId": "20003",
            "treeId": "4",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20599",
            "treeId": "10",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "9158",
            "treeId": "6",
            "nodeName": "treeId6-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "20002",
            "treeId": "3",
            "nodeName": "新人教A版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20005",
            "treeId": "6",
            "nodeName": "新人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "107",
            "treeId": "8",
            "nodeName": "人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "9190",
            "treeId": "8",
            "nodeName": "treeId8-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "9168",
            "treeId": "7",
            "nodeName": "treeId7-层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "36010",
            "treeId": "192",
            "nodeName": "新鲁科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 4
        },
        {
            "nodeId": "9109",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点2改编111",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "9122",
            "treeId": "4",
            "nodeName": "treeId4-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "9541",
            "treeId": "10",
            "nodeName": "教22",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "9094",
            "treeId": "2",
            "nodeName": "（西瓜添加）层级1-节点2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "20563",
            "treeId": "7",
            "nodeName": "新浙科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9466",
            "treeId": "9",
            "nodeName": "测试超过数目9",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20539",
            "treeId": "4",
            "nodeName": "新外研版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20601",
            "treeId": "10",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "20504",
            "treeId": "3",
            "nodeName": "新人教B版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20555",
            "treeId": "6",
            "nodeName": "新鲁科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "20506",
            "treeId": "3",
            "nodeName": "新湘教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "20557",
            "treeId": "6",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 5
        },
        {
            "nodeId": "9193",
            "treeId": "8",
            "nodeName": "treeId8-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "10596",
            "treeId": "2",
            "nodeName": "(小峰)层级1-1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "9169",
            "treeId": "7",
            "nodeName": "treeId7-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "9097",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "36012",
            "treeId": "192",
            "nodeName": "新教科版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 4
        },
        {
            "nodeId": "20565",
            "treeId": "7",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 6
        },
        {
            "nodeId": "10931",
            "treeId": "9",
            "nodeName": "测试一级节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20541",
            "treeId": "4",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20603",
            "treeId": "10",
            "nodeName": "新中图版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "20543",
            "treeId": "4",
            "nodeName": "新译林版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 3
        },
        {
            "nodeId": "20605",
            "treeId": "10",
            "nodeName": "新鲁教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 9
        },
        {
            "nodeId": "20508",
            "treeId": "3",
            "nodeName": "新苏教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "11029",
            "treeId": "8",
            "nodeName": "小峰政治1级",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 7
        },
        {
            "nodeId": "36014",
            "treeId": "192",
            "nodeName": "新粤教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 4
        },
        {
            "nodeId": "10912",
            "treeId": "9",
            "nodeName": "一级节点新增测试",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "10020",
            "treeId": "2",
            "nodeName": "（创业添加）",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "10936",
            "treeId": "9",
            "nodeName": "小峰1级",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "20512",
            "treeId": "3",
            "nodeName": "新北师大版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "9116",
            "treeId": "3",
            "nodeName": "treeId3-层级1-节点3",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 2
        },
        {
            "nodeId": "10172",
            "treeId": "2",
            "nodeName": "巴顿添加",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11030",
            "treeId": "9",
            "nodeName": "小峰1级2",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 8
        },
        {
            "nodeId": "9491",
            "treeId": "2",
            "nodeName": "（凯利添加）层级1-节点1",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "10184",
            "treeId": "2",
            "nodeName": "测试节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11151",
            "treeId": "2",
            "nodeName": "张伟伟测试2",
            "isShow": 1,
            "imageUrl": "https://test-si.ewt360.com/resources/school-admin/uploads/2024/10/31/8b79fd74-c91b-45e3-9b43-5d9cb8452853.png",
            "subjectId": 1
        },
        {
            "nodeId": "11418",
            "treeId": "2",
            "nodeName": "byt教材版本0919",
            "isShow": 1,
            "imageUrl": "https://test-si.ewt360.com/resources/school-admin/uploads/2024/10/31/8b79fd74-c91b-45e3-9b43-5d9cb8452853.png",
            "subjectId": 1
        },
        {
            "nodeId": "11467",
            "treeId": "2",
            "nodeName": "人教版",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11526",
            "treeId": "2",
            "nodeName": "有教材版本无书本节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11528",
            "treeId": "2",
            "nodeName": "有教材有书本无章节点",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11534",
            "treeId": "2",
            "nodeName": "有教材有书本有章节,章节资源为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        },
        {
            "nodeId": "11540",
            "treeId": "2",
            "nodeName": "有教材有书本有章有节,节点资源为空",
            "isShow": 1,
            "imageUrl": "",
            "subjectId": 1
        }
    ]

def json_list_to_excel(json_data, output_file='教材信息.xlsx'):
    """
    将JSON对象列表转换为Excel文件

    Args:
        json_data: JSON对象列表
        output_file: 输出的Excel文件名
    """

    # 方法1: 直接创建DataFrame并重命名列
    df = pd.DataFrame(json_data)

    # 选择需要的列并重命名
    df_selected = df[['subjectId', 'nodeName', 'nodeId']].copy()
    df_selected.columns = ['学科id', '教材名称', '基础目录教材id']

    # 导出到Excel
    df_selected.to_excel(output_file, index=False, engine='openpyxl')
    print(f"Excel文件已生成: {output_file}")

    return df_selected


def json_list_to_excel_advanced(json_data, output_file='教材信息_详细.xlsx'):
    """
    更高级的转换方法，包含数据处理和格式化

    Args:
        json_data: JSON对象列表
        output_file: 输出的Excel文件名
    """

    # 创建DataFrame
    df = pd.DataFrame(json_data)

    # 创建新的DataFrame，按需要的列顺序和名称
    result_df = pd.DataFrame({
        '学科id': df['subjectId'],
        '教材名称': df['nodeName'],
        '基础目录教材id': df['nodeId'],
        # 可选：添加其他有用的列
        '是否显示': df['isShow'].map({1: '是', 0: '否'}),
        '图片链接': df['imageUrl']
    })

    # 使用ExcelWriter进行更精细的控制
    with pd.ExcelWriter(output_file, engine='openpyxl') as writer:
        result_df.to_excel(writer, sheet_name='教材信息', index=False)

        # 获取工作表以进行格式化
        worksheet = writer.sheets['教材信息']

        # 调整列宽
        for column in worksheet.columns:
            max_length = 0
            column_letter = column[0].column_letter
            for cell in column:
                try:
                    if len(str(cell.value)) > max_length:
                        max_length = len(str(cell.value))
                except:
                    pass
            adjusted_width = min(max_length + 2, 50)
            worksheet.column_dimensions[column_letter].width = adjusted_width

    print(f"详细Excel文件已生成: {output_file}")
    return result_df


# 从JSON字符串解析的方法
def json_string_to_excel(json_string, output_file='教材信息_从字符串.xlsx'):
    """
    从JSON字符串转换为Excel

    Args:
        json_string: JSON格式的字符串
        output_file: 输出文件名
    """
    try:
        # 解析JSON字符串
        if isinstance(json_string, str):
            data = json.loads(json_string)
        else:
            data = json_string

        # 如果是单个对象，转换为列表
        if isinstance(data, dict):
            data = [data]

        return json_list_to_excel(data, output_file)

    except json.JSONDecodeError as e:
        print(f"JSON解析错误: {e}")
        return None


# 使用示例
if __name__ == "__main__":
    # 基础用法
    print("=== 基础转换 ===")
    output_file = "开发-教材信息.xlsx"
    df1 = json_list_to_excel(dev_json_data, output_file)
    print(df1)

    # print("\n=== 高级转换 ===")
    # df2 = json_list_to_excel_advanced(json_data)
    # print(df2)
    #
    # # 从JSON字符串转换
    # json_str = '''[
    #     {
    #         "nodeId": "514",
    #         "treeId": "3",
    #         "nodeName": "苏教版",
    #         "isShow": 1,
    #         "imageUrl": "https://example.com/image.jpg",
    #         "subjectId": 3
    #     }
    # ]'''
    #
    # print("\n=== 从JSON字符串转换 ===")
    # df3 = json_string_to_excel(json_str)
    # print(df3)


# 如果你的数据来源是文件
def read_json_file_to_excel(json_file_path, output_file='教材信息_从文件.xlsx'):
    """
    从JSON文件读取数据并转换为Excel

    Args:
        json_file_path: JSON文件路径
        output_file: 输出Excel文件名
    """
    try:
        with open(json_file_path, 'r', encoding='utf-8') as f:
            data = json.load(f)
        return json_list_to_excel(data, output_file)
    except FileNotFoundError:
        print(f"文件未找到: {json_file_path}")
        return None
    except Exception as e:
        print(f"读取文件错误: {e}")
        return None